#ifndef Player_H
#define Player_H
#include"cards.h"
#include"card.h"
#include <QObject>
#include <QMetaType>
//qRegisterMetaType<Cards&>();
class Player : public QObject
{
    Q_OBJECT
public:
    enum Role{Lord,Farmer};
    enum Sex{Man,Woman};
    enum Direction{Left,Right};
    enum Type{Robot,User,UnKnow};
    explicit Player(QObject *parent = nullptr);
    explicit Player(QString name,QObject *parent = nullptr);

    void setName(QString name);
    QString getName();

    void setRole(Role role);
    Role getRole();

    void setSex(Sex sex);
    Sex getSex();

    void setDirection(Direction direction);
    Direction getDirection();

    void setType(Type type);
    Type getType();

    void setScore(int score);
    int getScore();

    void setWin(bool flag);
    bool isWin();
    Player *getprevPlayer() const;
    void setPrevPlayer(Player *newPrev);
    Player *getnextPlayer() const;
    void setNextPlayer(Player *newNext);

    void grabLordBet(int point);

    //存储发的扑克牌
    void storeDispatchCard(const Card& card);
    void storeDispatchCard(const Cards& cards);

    Cards getCards();

    void clearCards();

    void playHand(Cards& cards);

    void storePendingInfo(Player *player,const Cards& cards);

    void setPendingInfo(Player *player,Cards& cards);
    Player* getpendplayer();
    Cards getpendCards();
    virtual void  prepareCallLord();
    virtual void  preparePlayHand();
    virtual void thinkCallLord();
    virtual void  thingkPlayHand();
signals:
    void notifyGrabLordBet(Player *player,int bet);
    void notifyPlayHand(Player *player,Cards &cards);
    void notifyPickCard(Player *player,const Cards &cards);
protected:
    QString m_name;
    Role m_role;
    Sex m_sex;
    Direction m_direction;
    Type m_type;
    int m_score = 0;
    bool m_iswin = false;
    Player *m_prev = nullptr;
    Player *m_next = nullptr;
    Cards m_cards;
    Player *m_pendPlayer = nullptr	;
    Cards m_pendCards;
};

#endif // Player_H
